package com.zhaopin.thread;

import java.util.Objects;

/**
 * @author yin.peide
 * @date 2021-06-23 10:24
 */
public class DeadLock {

    public static void main(String[] args) throws InterruptedException {
        Object room1 = new Object();
        Object room2 = new Object();
        Thread t1 = new Thread(() -> {
            synchronized (room1){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (room2){
                    System.out.println("1111");
                }
            }
        });
        t1.start();
        new Thread(() -> {
            synchronized (room2){
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                synchronized (room1){
                    System.out.println("2222");
                }
            }
        }).start();

        Thread.sleep(500);
//        t1.interrupt();

    }
}
